<template>
	<view>
		<view :class="noDiv ? 'cu-custom nodiv' : 'cu-custom'" :style="[{height:CustomBar + 'px'}]">
			<view class="cu-bar fixed" :style="style" :class="[bgImage==''?'none-bg text-white bg-img':'',bgColor]">
				<view class="action" @tap="BackPage" v-if="isBack">
					<text class="cuIcon-back"></text>
					<slot name="backText"></slot>
				</view>
				<view class="content" :style="[{top:StatusBar + 'px'}]">
					<slot name="content"></slot>
				</view>
				<slot name="right"></slot>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				StatusBar: this.StatusBar,
				CustomBar: this.CustomBar
			};
		},
		name: 'cu-custom',
		computed: {
			style() {
				var StatusBar= this.StatusBar;
				var CustomBar= this.CustomBar;
				var bgImage = this.bgImage;
				var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
				if (this.bgImage) {
					style = `${style}background-image:url(${bgImage})!important;background-size: 100vw 79.8px!important`;
				}
				return style
			},
		},
		props: {
			bgColor: {
				type: String,
				default: ''
			},
			isBack: {
				type: [Boolean, String],
				default: false
			},
			bgImage: {
				type: String,
				default: ''
			},
			noDiv: {
				type: [Boolean, String],
				default: false
			},
		},
		methods: {
			BackPage() {
				uni.navigateBack({
					delta: 1
				});
			}
		}
	}
</script>

<style lang="scss">
	.cu-custom{
		background-size:  100vw 79.8px;
		// background-color: green!important;
		&.nodiv{
			position: absolute;
			top: 0;
			width: 100vw;
			z-index: 100;
		}
		.cu-bar{
			background-image: url('@/static/img/img_top_area.jpg')!important;
			// background: #d6001c;
			background-size:  100vw 22.5vw;
			// background-image: url('@/static/img/img_homepage_top_banner_01_01.jpg')!important;
			// background-size: 100% 305px;
			// background-repeat: no-repeat;
			// background: red !important;
		}
	}
</style>
